package ckw.database.repositories;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import ckw.database.model.ElectionNode;
import ckw.database.model.ElectionResidentVoter;
import ckw.database.model.Voter;

@Transactional
public interface ElectionResidentVoterRepository extends JpaRepository<ElectionResidentVoter, Long> {

	ElectionResidentVoter findByVoterAndElectionNode(Voter voter, ElectionNode electionNode);

	@Query("From ElectionResidentVoter v WHERE v.voter.identificationField = :vId AND v.electionNode.election.identificationField = :eId")
	ElectionResidentVoter getResidentVoterByVoterIdentificationFieldAndElectionIdentificationField(@Param("vId") String vId, @Param("eId") Long electionIdentificationField);
}
